package dataStructureAlgorithms.linkList;

/**
 * @Description: TODO 单链表
 * @Author: wzj
 * @Date: 2019/10/9 8:18
 */
public class Node {
    private int data;
    private Node next;

    public Node(int data) {
        this.data = data;
    }

    public Node insert(Node node){
        Node thisNext=next;
        next=node;
        node.next=thisNext;
        return this;
    }

    public Node remove(){
        if(next!=null){
            next=next.next;
        }
        return this;
    }

    /**
     * 遍历
     */
    public void traverse(){
        System.out.print(data+" ");
        while(next!=null){
            System.out.print(next.data+" ");
            next=next.next;
        }
    }
}
